<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
	<head>
		<title>购彩大厅</title>
		<%@include file="/WEB-INF/base.jspf"%>
		<link rel="stylesheet" href="/css/style.css" />
		<style>
			*{font-size: 16px;}
			.gray{font-size: 14px;}
			.name{font-weight: bold;}
			.not1{color: red;font-size: 14px;margin-top: 5px;}
			
			.cai1{float: left;padding-top: 70px;}
			.cai1 li{float: left;width: 33.3%;border-top: 1px solid #f0f0f0;padding: 10px 0px;}
			.cai1 img{width: 70px;height: 70px;}
			.cai1 .not,.cai1 .not1,.cai1 .br1,.cai1 .qishu{display: none;}
			
			.cai2{margin-top: 0px;}
			.cai2 li{margin-top: 20px; height: 80px;border-top: 1px solid #f0f0f0;margin-top: 8px;padding-top: 8px;}
			.cai2 img{width: 60px;height: 60px;margin:6px 10px 0px 0px;}
			.cai2 .not{left: 80px;position: absolute;margin-top: 8px;}
			.cai2 .djs,.cai2 .qishu{right: 10px;position: absolute;}
			.djs{margin-top: 8px;color: red;font-weight: bold;}
			.cai2 .br{display: none;}
			.cai2 img,.cai2 .name,.cai2 .not1{float: left;}
		</style>
	</head>
	<body>
		<div class="bg-theme col-xs-12 col-sm-4 col-sm-offset-4 text-center top">
			<span>　购彩大厅</span>
			<span id="hhh" class="glyphicon glyphicon-th-large fr" onclick="changImg()" style="margin-top : 8px;font-size: 25px;"></span>
		</div>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center nav1" style="height: 30px;line-height: 30px;position: fixed;top: 40px;z-index: 50;background:#4F84CF ;">
			<select style="border: 0;background: #4F84CF ;outline: none; font-size: 15px;font-weight: bold;color: white;">
				<option value="cz" selected="selected">全部彩种(点击选择) </option>
				<option value="ssc">时时彩(点击选择) </option>
				<option value="pcdd">PC蛋蛋(点击选择) </option>
				<option value="pk10">PK拾(点击选择) </option>
				<option value="115">11选5(点击选择) </option>
				<option value="kuai3">快3(点击选择) </option>
				<option value="gpc">高频彩(点击选择) </option>
				<option value="dpc">低频彩(点击选择) </option>
			</select>
		</div>
		<div id="cai" class="col-xs-12 col-sm-4 col-sm-offset-4 text-center body cai2" style="padding: 60px 10px;">
		</div>
		<div class="col-xs-12 col-sm-4 col-sm-offset-4 text-center foot">
			<iframe src="f.jsp"></iframe>
		</div>
	</body>
	<script>
		$(function(){
			$(".nav1 select").change(function(){
				var cla=$(".nav1 select").val();
				$(".cz").addClass("hidden");
				$("."+cla).removeClass("hidden");
			});
			reload();
		});
		function startDjs(he,lasttime,timespace){
			var time1 = new Date().format("hh:mm:ss").split(":");
			time1=Number(time1[0]*60*60)+Number(time1[1]*60)+Number(time1[2]);
			var time=lasttime.split(":");
			time=Number(time[0]*60*60)+Number(time[1]*60)+Number(time[2]);
			time=time+Number(timespace)-time1;
			var dd=window.setInterval(function(){
				time--;
				var hour=Math.floor(time/3600);
				var minute=Math.floor((time-hour*3600)/60);
				var second=time-hour*3600-minute*60;
				$("#djs"+he).text(bu0(hour)+":"+bu0(minute)+":"+bu0(second));
				if(time<0){
					/* clearInterval(dd); */
					$("#djs"+he).text("正在开奖…");
					var s=$("#djs"+he).parent().attr("class");
					s=s.substr(0,s.indexOf(" "));
					getnewdata(s);
				}
			},1000);
		}
		function getnewdata(s) {
			ajax({
				url:'/lotter/getnewdata.do',
				type:'post',
				data:{key:s},
				success:function(data){
					var json=eval('('+data+')');
					if($("."+s+" .qishu").text().replace("第","").replace("期","")==json.data.period){
						setTimeout(function(){getnewdata(s);},3000);
					}else{
						$("."+s+" .qishu").text("第"+json.data.period+"期");
						$("."+s+" .not").text("距"+(Number(json.data.period)+1)+"期截止还有");
						$("."+s+" .not1").text(json.data.lotternumber.replace(","," "));
						$("."+s+" .djs").text("dddddddddddd");
					}
						/*startDjs(i,data[i].lottertime,data[i].timespace); */
				}
			});
		}
		function reload(){
			$("#cai").html("");
			ajax({
				url:'/lotter/getlotters.do',
				type:'post',
				success:function(data){
					var json=eval('('+data+')');
					if(json.state==1){
						data=json.data;
						for(var i=0;i<data.length;i++){
							$("#cai").append("<li class='"+data[i].classt+"' href='/lotter/lot.do?zl="+data[i].cname+"'>"
								+ "<img src='img/caizhong/"+data[i].img+".png' /><br class='br'>"
								+ "<span class='name'>"+data[i].name+"</span><span class='qishu gray'>第"+data[i].period+"期</span><br class='br1'>"
								+ "<span class='not1'>"+data[i].lotternumber+"</span><br>"
								+ "<span class='not gray'>距"+(Number(data[i].period)+1)+"期截止还有</span>"
								+ "<span id='djs"+i+"' class='djs gray'></span>"
								+ "</li>");
							startDjs(i,data[i].lottertime,data[i].timespace);
						}
						var ha=$(".klpk .not1").text().split(" ");
						var ss="";
						for(var j=0;j<ha.length;j++){
							ss+=fenli(ha[j]);
						}
						$(".klpk .not1").html(ss);
						$("#cai li").click(function(){
							window.location.href=$(this).attr("href");
						});
					}else{
						alert("获取数据失败");
					}
				}
			});
		}
	</script>
</html>
